package step_2.players.random;

import java.util.Random;

import step_2.checkers_board.Board;
import step_2.checkers_board.CheckersMove;
import step_2.players.Player;

public class RandomPlayer implements Player {

	private Random random;

	public RandomPlayer() {
		random = new Random();
	}

	@Override
	public CheckersMove getMove(Board board) {
		final CheckersMove[] legalMoves = board.getLegalMoves();  
		final int minMove = 0;
		final int maxMove = legalMoves.length;
		final int nMovesAllowed = maxMove - minMove;
		final int moveIndex = random.nextInt(nMovesAllowed) + minMove;
		final CheckersMove move = legalMoves[moveIndex];

		return move;
	}

}
